<template>
	<view class="card">
		<view class="item">
			<view class="header flex">
				<divimg class="img" :src="fromData.img"></divimg>
				<view class="box spaceBetween">
					<view class="user_name">
						{{ fromData.user_name }}
					</view>
					
					<view v-if="myShare" class=" job">
						{{ fromData.job }}
					</view>
					<view  v-if="myShare" class=" name">
						{{ fromData.name }}
					</view>
				</view>
				<view class="opt" v-if="!myShare">
					<view class="optItem right" @click="share">
						<image class="icon" src="/static/images/share.png" mode=""></image>
						<view class="txt">分享</view>
					</view>
					<view class="optItem right" @click="FavoriteEdit">
						<image class="icon" v-show="!fromData.is_favorite || fromData.is_favorite === 0" src="/static/images/collection.png" mode=""></image>
						<image class="icon" v-show="fromData.is_favorite == 1" src="/static/images/collectionAct.png" mode=""></image>
						<view class="txt">收藏</view>
					</view>
				</view>
			</view>
			<view class="line name" v-if="!myShare">
				公司：
				<text class="text">{{ fromData.name }}</text>
			</view>
			<view class="line job" v-if="!myShare">
				职位：
				<text class="text">{{ fromData.job }}</text>
			</view>
			<view class="line address clamp">
				所在地区：
				<text class="text">{{ fromData.address }}</text>
			</view>
			<view class="line profession clamp">
				所属行业：
				<text class="text">{{ fromData.profession }}</text>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	name: 'card',
	props: {
		fromData: {
			type: Object,
			default: () => {}
		},
		myShare:false,
	},
	data() {
		return {};
	},
	methods: {
		share() {
			uni.setStorageSync('groupDetails', this.fromData);
			const url = 'pages/group/details/details?id='+this.fromData.id ;
			uni.navigateTo({
				url: '/pages/group/share/share?page=' + url
			});
		},
		async FavoriteEdit() {
			const res = await this.$api.FavoriteEdit({ type: 1, id: this.fromData.id });
			this.$emit('FavoriteEdit');
		}
	}
};
</script>
<style lang="scss" scoped>
.item {
	margin: $submargin-width auto;
	width: $connet-width;
	min-height: 250rpx;
	overflow: hidden;
	background: #ffffff;
	border-radius: 20rpx;
	.header {
		position: relative;
		overflow: hidden;
		padding-bottom: $submargin-width;
		border-bottom: 1rpx solid #dddddd;
		width: 650rpx;
		margin: 0 auto;
		.img {
			margin: $submargin-width;
			width: 120rpx;
			height: 120rpx;
			border-radius: 50%;
			overflow: hidden;
		}
		.box {
			flex-direction: column;
			height: 120rpx;
			margin: $submargin-width;
			.user_name {
				font-size: $uni-font-size-14;
				font-family: Source Han Sans CN, Source Han Sans CN;
				font-weight: bold;
				color: #000000;
			}
			.job {
				font-size: $uni-font-size-12;
				color: #1fc28b;
			}
			.name {
				color: #000000;
				font-size: $uni-font-size-12;
			}
		}
		.opt {
			overflow: hidden;
			position: absolute;
			right: $margin-width;
			top: 50rpx;
			.optItem {
				overflow: hidden;
				color: #000000;
				font-size: $uni-font-size-10;
				text-align: center;
				display: flex;
				flex-direction: column;
				align-items: center;
				margin-right: $margin-width;
				.icon {
					width: 30rpx;
					height: 30rpx;
					margin-bottom: 10rpx;
				}
			}
		}
	}
	.line {
		color: #999999;
		margin: $submargin-width;
		font-size: $uni-font-size-12;
		.text {
			color: #000000;
		}
	}
	.job {
		.text {
			color: #1fc28b;
		}
	}
}
</style>
